package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第二页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamTenthActivity extends AbstractControlActivity implements
		OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_tenth);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addEditTextView(R.id.edt_ruyuanriqi, "入院日期");
		addEditTextView(R.id.edt_chuyuanriqi, "出院日期");
		addEditTextView(R.id.edt_ruyuanyuanyin, "住院原因");
		addEditTextView(R.id.edt_yiyuanmingcheng, "医疗机构名称");
		addEditTextView(R.id.edt_zhuyuanbah, "住院史病案号");
		addEditTextView(R.id.edt_jianchuangriqi, "建床日期");
		addEditTextView(R.id.edt_chechuangriqi, "撤床日期");
		addEditTextView(R.id.edt_jiatingbcyy, "家庭病床原因");
		addEditTextView(R.id.edt_jiatingbcyljgmc, "家庭病床医疗机构名称");
		addEditTextView(R.id.edt_jiatingbsbah, "家庭病案病案号");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_ruyuanriqi);
		setEditTextListener(R.id.edt_chuyuanriqi);
		setEditTextListener(R.id.edt_jianchuangriqi);
		setEditTextListener(R.id.edt_chechuangriqi);
		this.setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			// 前一页按钮
			intent.setClass(this, HealthExamNinthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamEleventhActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
